package com.tc.service;


import com.tc.base.BaseService;
import com.tc.mapper.SysUserMapper;
import com.tc.util.Ognl;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/12/25 0025.
 */
@Service
public class SysUserService extends BaseService {

    public static final Log logger = LogFactory.getLog(SysUserService.class.getName());

    @Autowired
    SysUserMapper sysUserMapper;

    public Map<String, Object> getUserByUserIdPassword(String USER_ID, String PASSWORD) {
        /*if(1==1){
            Map<String, Object> user = new HashMap<String, Object>();
            user.put("SWRY_DM","admin");
            user.put("USERPASSWORD","21232f297a57a5a743894a0e4a801fc3");

            return user;
        }*/
        Map<String, String> params = new HashMap<String, String>();
        params.put("username", USER_ID);
        if (PASSWORD != null) {
            params.put("password", PASSWORD);
        }else{
            params.put("password",null);
        }

        try {
            List<Map<String, Object>> list = sysUserMapper.getUserList(params);
            if (Ognl.isNotEmpty(list)) {
                logger.debug("success getUser:" + USER_ID + "," + PASSWORD);
                return list.get(0);
            } else {

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public Map<String, Object> getUserByUserId(String USER_ID) {
        return this.getUserByUserIdPassword(USER_ID, null);
    }




}
